package y2017.m10.d11;

import java.util.Calendar;

public class Countdown {
    public static void main(String[] args) throws InterruptedException {
        while (true) {
            int hour, minute, second;
            Calendar now = Calendar.getInstance();
            Calendar instance = Calendar.getInstance();
            instance.set(Calendar.HOUR_OF_DAY, 18);
            instance.set(Calendar.MINUTE, 0);
            instance.set(Calendar.SECOND, 0);
            long timeInMillis = instance.getTimeInMillis();
            long diff = (timeInMillis - now.getTimeInMillis()) / 1000;
            if (diff < 0)
                diff += 24 * 3600;
            if (diff == 0)
                break;
            hour = (int) diff / 3600;
            minute = (int) (diff - hour * 3600) / 60;
            second = (int) diff % 60;
            System.out.println("还剩" + hour + "小时" + minute + "分" + second + "秒下班了");
            Thread.sleep(1000);
        }
    }
}
